/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
extern uint8_t data_flag;
extern uint8_t rx_flag;
extern uint8_t rx_data;
extern uint8_t rx_buffer[10];
/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define REP_RATE 1
#define CKTIM 240000000
#define DEADTIME_NS 1000
#define POLE_PAIR_NUM 10
#define PWM_PRSC 0
#define ICx_FILTER 8
#define PWM_FREQ 20000
#define COUNTER_RESET (ALIGENMENT_ANGLE*4*ENCOUDER_PPR/360-1)/POLE_PAIR_NUM
#define PWM_PERIOD CKTIM/(2*PWM_FREQ*(PWM_PRSC+1))
#define DEADTIME 50
#define ENCODER_PPR 2500
#define ADC_SW0_Pin GPIO_PIN_3
#define ADC_SW0_GPIO_Port GPIOE
#define ADC_SW1_Pin GPIO_PIN_2
#define ADC_SW1_GPIO_Port GPIOE
#define ADC_SW2_Pin GPIO_PIN_1
#define ADC_SW2_GPIO_Port GPIOE
#define SPI1_CS_Pin GPIO_PIN_10
#define SPI1_CS_GPIO_Port GPIOG
#define HALL_5VSW2_Pin GPIO_PIN_8
#define HALL_5VSW2_GPIO_Port GPIOI
#define HALL_5VSW1_Pin GPIO_PIN_11
#define HALL_5VSW1_GPIO_Port GPIOI
#define HALL_5VSW1_EXTI_IRQn EXTI15_10_IRQn
#define LED_4_Pin GPIO_PIN_12
#define LED_4_GPIO_Port GPIOH
#define LED_3_Pin GPIO_PIN_5
#define LED_3_GPIO_Port GPIOG
#define LED_2_Pin GPIO_PIN_4
#define LED_2_GPIO_Port GPIOG
#define LED_1_Pin GPIO_PIN_3
#define LED_1_GPIO_Port GPIOG
#define ECAT_IRQ_Pin GPIO_PIN_1
#define ECAT_IRQ_GPIO_Port GPIOG
#define ECAT_IRQ_EXTI_IRQn EXTI1_IRQn
#define ECAT_SYNC0_Pin GPIO_PIN_14
#define ECAT_SYNC0_GPIO_Port GPIOB
#define ECAT_SYNC0_EXTI_IRQn EXTI15_10_IRQn
#define ECAT_SYNC1_Pin GPIO_PIN_15
#define ECAT_SYNC1_GPIO_Port GPIOB
#define ECAT_SYNC1_EXTI_IRQn EXTI15_10_IRQn

/* USER CODE BEGIN Private defines */
#define False 0
#define True 1
/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
